package wassalt.Utils;

import wassalt.client.NotificationsListActivity;
import wassalt.client.R;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;

public class StatusBarNotification {

	static int sysNotifCounter = 0;
	static final String NOTIF_ID="notification_id";
	
	/**
	 * @author Aya Kamel, Gad
	 * @param title The title of the notification
	 * @param text The text of the notification
	 * Shows a notification on the status bar
	 */
	public static void show(Context context,CharSequence title, CharSequence text){
		
		String ns = Context.NOTIFICATION_SERVICE;
		NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns);
		
		int icon = R.drawable.car;
		long time = System.currentTimeMillis();
		
		Notification notification = new Notification(icon, title, time);
		notification.defaults |= Notification.DEFAULT_SOUND;
		notification.defaults |= Notification.DEFAULT_VIBRATE;
		notification.defaults |= Notification.DEFAULT_LIGHTS;
		long[] vibrate = {100, 100, 100};
		notification.vibrate = vibrate;
		notification.ledARGB = 0xff00ff00;
		notification.ledOnMS = 300;
		notification.ledOffMS = 1000;
		notification.flags |= Notification.FLAG_SHOW_LIGHTS;
		notification.flags |= Notification.FLAG_AUTO_CANCEL;
		Intent notificationIntent = new Intent(context, NotificationsListActivity.class);
		notificationIntent.putExtra(NOTIF_ID, sysNotifCounter);
		notificationIntent.putExtra("Notif_title", title);
		notificationIntent.putExtra("Notif_text", text);
		sysNotifCounter ++;
		PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);

		notification.setLatestEventInfo(context, title, text, contentIntent);
		mNotificationManager.notify(sysNotifCounter, notification);
	}

}
